package com.miszczu.model;
// Generated 2012-03-05 20:16:25 by Hibernate Tools 3.4.0.CR1


import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Subjects generated by hbm2java
 */
@Entity
@Table(name="subjects"
    ,catalog="dziennik"
)
public class Subjects  implements java.io.Serializable {


     private Integer subjectId;
     private String subjectName;
     private Set<Grades> gradeses = new HashSet<Grades>(0);
     private Set<Classes> classeses = new HashSet<Classes>(0);

    public Subjects() {
    }

	
    public Subjects(String subjectName) {
        this.subjectName = subjectName;
    }
    public Subjects(String subjectName, Set<Grades> gradeses, Set<Classes> classeses) {
       this.subjectName = subjectName;
       this.gradeses = gradeses;
       this.classeses = classeses;
    }
   
     @Id @GeneratedValue(strategy=IDENTITY)

    
    @Column(name="subject_id", unique=true, nullable=false)
    public Integer getSubjectId() {
        return this.subjectId;
    }
    
    public void setSubjectId(Integer subjectId) {
        this.subjectId = subjectId;
    }

    
    @Column(name="subject_name", nullable=false, length=100)
    public String getSubjectName() {
        return this.subjectName;
    }
    
    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

@OneToMany(fetch=FetchType.LAZY, mappedBy="subjects")
    public Set<Grades> getGradeses() {
        return this.gradeses;
    }
    
    public void setGradeses(Set<Grades> gradeses) {
        this.gradeses = gradeses;
    }

@ManyToMany(fetch=FetchType.EAGER)
    @JoinTable(name="classessubjects", catalog="dziennik", joinColumns = { 
        @JoinColumn(name="Subjects_subject_id", nullable=false, updatable=false) }, inverseJoinColumns = { 
        @JoinColumn(name="Classes_class_id", nullable=false, updatable=false) })
    public Set<Classes> getClasseses() {
        return this.classeses;
    }
    
    public void setClasseses(Set<Classes> classeses) {
        this.classeses = classeses;
    }

    @Override
    public boolean equals(Object obj) {
    	
    	Subjects sObj = (Subjects) obj;
    	if(sObj.getSubjectId() == this.getSubjectId()) {
    		return true;
    	}

    	return false;
    }


}


